<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.shopping.modean.*" %>
<%@ page import="com.shopping.service.*" %>
<%@ page import="java.util.*" %>


<%
	User u = (User)session.getAttribute("user");
	List<Product> lasterProducts =  ProductService.getInstance().getLasterProducts(10);

%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户首页</title>
</head>
<body>
  <%if(u == null) {%>	  
  	  <a href="login.jsp">登录</a>
  	  <a href="user_register.jsp">注册</a>
  <%} else {%>
	  <a href="user_self_service.jsp"><%=u.getUsername() %></a> 欢迎您！
	  <a href="cart.jsp">购物车</a>
	  <a href="">退出</a>  
  <%}%>
  
  <div>
    <p>最新商品</p>
  	<ul>
  	  <%
  	     for(Product p : lasterProducts) {
  	    	 out.println("<li><a href='product_detail.jsp?id=" + p.getId() + "'>" + p.getDescr() + "</a></li>");
  	     }
  	  %>
  	</ul>
  
  </div>
  
  
</body>
</html>